package com.yxhl.zoume.core.func.appraisal.ui.activity;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;

import com.yxhl.zoume.R;
import com.yxhl.zoume.common.ui.activity.base.BaseActivityWithToolBar;
import com.yxhl.zoume.core.specialcar.model.SpecialCarContainerEntrance;
import com.yxhl.zoume.core.specialcar.model.SpecialCarContainerActivityParam;
import com.yxhl.zoume.core.func.appraisal.model.AppraisalDriverInfo;
import com.yxhl.zoume.core.func.appraisal.ui.fragment.AppraisalFragment;
import com.yxhl.zoume.di.component.appraisal.AppraisalComponent;
import com.yxhl.zoume.di.component.appraisal.DaggerAppraisalComponent;
import com.yxhl.zoume.di.component.base.HasComponent;
import com.yxhl.zoume.di.module.ActivityModule;

/**
 * Created by vhawk on 16/9/18.
 */
public class AppraisalActivity extends BaseActivityWithToolBar implements HasComponent<AppraisalComponent> {

    private static final String KEY_APPRAISAL_PARAM = "APPRAISAL_PARAM";
    private AppraisalDriverInfo driverInfo;
    private AppraisalComponent component;

    public static Intent getCallingIntent(Activity activity, AppraisalDriverInfo driverInfo) {
        Intent intent = new Intent(activity, AppraisalActivity.class);
        intent.putExtra(KEY_APPRAISAL_PARAM, driverInfo);
        return intent;
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        handleIntent();
        addFragment(R.id.frame_activity_appraisal_body, AppraisalFragment.newInstance(driverInfo));
    }

    private void handleIntent() {
        driverInfo = (AppraisalDriverInfo) getIntent().getSerializableExtra(KEY_APPRAISAL_PARAM);
    }

    @Override
    protected void onHeaderLeftClick(View view) {
//        getAppComponent().navigator().navigateToSpecialCarContainerActivity(this, new SpecialCarContainerActivityParam(SpecialCarContainerEntrance.SPECIAL_CAR_HOME));
        finish();
    }

    @Override
    public void onBackPressed() {
        super.onBackPressed();
//        getAppComponent().navigator().navigateToSpecialCarContainerActivity(this, new SpecialCarContainerActivityParam(SpecialCarContainerEntrance.SPECIAL_CAR_HOME));
    }

    @Override
    protected void onHeaderRightClick(View view) {

    }

    @Override
    protected int getLayoutResId() {
        return R.layout.activity_appraisal;
    }

    @Override
    protected void initializeInjector() {
        component = DaggerAppraisalComponent.builder()
                .appComponent(getAppComponent())
                .activityModule(new ActivityModule(this))
                .build();
    }

    @Override
    public AppraisalComponent getComponent() {
        return component;
    }
}
